import {getLocalStorage} from "@/utils/storage";
import {StorageEnum} from '@/enums/storeageEnum'
import {LangEnum} from "@/enums/styleEnum";
import {LangStateType} from "@/store/modules/langStore/langStore";
import {createI18n} from "vue-i18n";
import {lang} from "@/settings/designSetting";
import zh from './zh/index'
import en from './en/index'

const langStorage: LangStateType = getLocalStorage(StorageEnum.GO_LANG_STORE)

export const langList = [
    {
        label: '中文',
        key: LangEnum.ZH
    },
    {
        label: 'English',
        key: LangEnum.EN
    }
]

// un-know
const i18n = createI18n({
    legacy: false,
    globalInjection: true,
    locale: langStorage?.lang || lang,
    fallbackLocale: langStorage?.lang || lang,
    messages: {
        [LangEnum.ZH]: zh,
        [LangEnum.EN]: en
    }
})

export default i18n